<h1>ZC12 Introducing Zend View Helpers</h1>
<h2>ZC13 Zend _View Helpers With Ajax</h2>
<br><br>

<label for="msg"> Notice </label>
<input type="text" name="msg" id="msg" />
<a href="#" id="getNotice"> get notice!</a> | <a href="#" id="clearNotice"> Clear notice!</a>


<div id="notices"></div>

<? //echo $this->notice('Create user account')?>
<? //echo $this->notice('Email user!')?>

<script type="text/javascript">
    $(function()
    {
        $('#getNotice').click(function()
        {
            getAjaxNotice(0);
            return false;
        });
        $('#clearNotice').click(function()
        {
            getAjaxNotice(1);
            return false;
        });
    });

    function getAjaxNotice(clearSession)
    {
        $.post(
            "/async/getnotice",
            {
                'msg' : $('#msg').val(),
                'clear' : clearSession
            },
            function(data)
            {
                var notice = $(data);

                $('#notices').prepend(notice.hide().fadeIn());
                
                setTimeout(function(emt){
                    emt.fadeOut('slow',function(){
                        $(this).remove();
                    })
                }, 1500 , notice);
            }
        );
    }
</script>